unit UNumPad;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  FMX.StdCtrls,UDialog, FMX.Objects, FMX.Edit;

type
  TNumPadDialog = class(TDialogFrame)
    ok: TButton;
    Number0: TButton;
    Dot: TButton;
    Cancel: TButton;
    Number3: TButton;
    Number2: TButton;
    Number1: TButton;
    Number4: TButton;
    Number5: TButton;
    Number6: TButton;
    Clear: TButton;
    Number9: TButton;
    Number8: TButton;
    Number7: TButton;
    lbTitle: TLabel;
    resultBox: TEdit;
    Line1: TLine;
    procedure Number1Click(Sender: TObject);
    procedure Number2Click(Sender: TObject);
    procedure Number3Click(Sender: TObject);
    procedure Number4Click(Sender: TObject);
    procedure Number5Click(Sender: TObject);
    procedure Number6Click(Sender: TObject);
    procedure Number7Click(Sender: TObject);
    procedure Number8Click(Sender: TObject);
    procedure Number9Click(Sender: TObject);
    procedure ClearClick(Sender: TObject);
    procedure Number0Click(Sender: TObject);
    procedure DotClick(Sender: TObject);
    procedure okClick(Sender: TObject);

    procedure CancelClick(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

procedure TNumPadDialog.CancelClick(Sender: TObject);
begin
  resultBox.Text := '';
  self.DialogResult := mrCancel;
  FProcessDialogResult.ProcessDialogResult;
end;

procedure TNumPadDialog.ClearClick(Sender: TObject);
begin
  resultBox.Text := '';
end;

procedure TNumPadDialog.DotClick(Sender: TObject);
var
  I: Integer;
  isdot: Integer;
begin
  for I := 0 to resultBox.Text.Length - 1 do
  begin
    if resultBox.Text[I] = '.' then
      isdot := 1;
  end;
  if isdot <> 1 then
    resultBox.Text := resultBox.Text + '.';
end;

procedure TNumPadDialog.Number0Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(0);
end;

procedure TNumPadDialog.Number1Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(1);
end;

procedure TNumPadDialog.Number2Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(2);
end;

procedure TNumPadDialog.Number3Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(3);
end;

procedure TNumPadDialog.Number4Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(4);
end;

procedure TNumPadDialog.Number5Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(5);
end;

procedure TNumPadDialog.Number6Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(6);
end;

procedure TNumPadDialog.Number7Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(7);
end;

procedure TNumPadDialog.Number8Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(8);
end;

procedure TNumPadDialog.Number9Click(Sender: TObject);
begin
  resultBox.Text := resultBox.Text + IntToStr(9);
end;

procedure TNumPadDialog.okClick(Sender: TObject);
begin
  ReturnString := resultBox.Text;
  DialogResult := mrOK;
  FProcessDialogResult.ProcessDialogResult;
end;


end.
